home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 11 - 1995 / 11.04 Apr 95 / TreeAppƒ / Application Shellƒ / CPPString.cp next >
Encoding:
Text File  |  1996-04-04  |  2.3 KB  |  95 lines  |  [TEXT/KAHL]

  1. /***************************************************** IMPLEMENTATION
  2.     DATE:    9/15/93
  3.     AUTHOR: Eric R. Rosé
  4.  
  5.     CLASS:  CPPString
  6.     
  7.     SUPERCLASS: none
  8.     
  9.         This will be the base class for all of our C++ objects
  10.     
  11. ********************************************************************/
  12.  
  13. #include "CPPString.h"
  14. #include <StringTools.h>
  15. #include <MemoryTools.h>
  16.  
  17. /*-----------------------------------------------------------------*/
  18. /*------------------------ PUBLIC METHODS -------------------------*/
  19. /*-----------------------------------------------------------------*/
  20.  
  21.     CPPString::CPPString (void)
  22.     /* The base class has no data to initialize */
  23.     {
  24.         this->theString = NULL;
  25.         this->ownsString = FALSE;
  26.     }
  27.  
  28. /*-----------------------------------------------------------------*/
  29.  
  30.     CPPString::CPPString (StringPtr newString, Boolean becomeOwner)
  31.     /* The base class has no data to initialize */
  32.     {
  33.         this->theString = newString;
  34.         this->ownsString = becomeOwner;
  35.     }
  36.  
  37. /*-----------------------------------------------------------------*/
  38.  
  39.     CPPString::~CPPString (void)
  40.     /* The base class has no data to destroy */
  41.     {
  42.         if (this->ownsString)
  43.           NukePtr(this->theString);
  44.     }
  45.  
  46. /*-----------------------------------------------------------------*/
  47.  
  48.     Boolean    CPPString::Member (char *className)
  49.     {
  50.         if (strcmp(className, CPPString::ClassName()) == 0)
  51.           return TRUE;
  52.         else
  53.           return CPPObject::Member(className);
  54.     }
  55.  
  56. /*-----------------------------------------------------------------*/
  57.  
  58.     char    *CPPString::ClassName (void)
  59.     {
  60.         return "CPPString";
  61.     }
  62.  
  63. /*-----------------------------------------------------------------*/
  64.  
  65.     CPPObject    *CPPString::Clone (void)
  66.     /* The base class has no data to copy */
  67.     {
  68.         CPPString    *NewString = new CPPString (this->theString, TRUE);
  69.         
  70.         return (CPPObject *)NewString;
  71.     }
  72.  
  73. /*-----------------------------------------------------------------*/
  74.  
  75.     StringPtr    CPPString::GetString (Boolean getCopy)
  76.     {
  77.         if (getCopy)
  78.           return String2String(this->theString);
  79.         else
  80.           return theString;
  81.     }
  82.  
  83. /*-----------------------------------------------------------------*/
  84.  
  85.     void    CPPString::SetString (StringPtr newString, Boolean becomeOwner)
  86.     {
  87.         if (this->ownsString)
  88.           NukePtr(this->theString);
  89.           
  90.         this->theString = newString;
  91.         this->ownsString = becomeOwner;
  92.     }
  93.  
  94. /*-----------------------------------------------------------------*/
  95.